﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace GraphicFNN
{
    /// <summary>
    /// Логика взаимодействия для MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private void _paintButtons(Button activeButton)
        {
            var nonActiveBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFE8E8E8"));
            BtnActivity.Background = nonActiveBrush;
            BtnCreation.Background = nonActiveBrush;
            BtnCultivation.Background = nonActiveBrush;
            BtnTraining.Background = nonActiveBrush;
            BtnTraining.BorderThickness = new Thickness(1, 1, 2, 2);
            BtnCultivation.BorderThickness = new Thickness(1, 1, 2, 2);
            BtnActivity.BorderThickness = new Thickness(1, 1, 2, 2);
            BtnCreation.BorderThickness = new Thickness(1, 1, 2, 2);

            activeButton.Background = Brushes.Beige;
            activeButton.BorderThickness = new Thickness(0, 5, 0, 0);
            activeButton.Background = Brushes.White;
            activeButton.Padding = new Thickness(5);
        }

        public MainWindow()
        {
            InitializeComponent();
            _paintButtons(BtnTraining);
        }

        private void BtnCreation_OnClick(object sender, RoutedEventArgs e)
        {
            var targetPage = new Uri("/Pages/CreationPage.xaml", UriKind.Relative);
            if (!FrmMain.Source.OriginalString.Contains("CreationPage.xaml"))
            {
                FrmMain.Navigate(targetPage);
                _paintButtons(BtnCreation);
            }
        }

        private void BtnTraining_OnClick(object sender, RoutedEventArgs e)
        {
            var targetPage = new Uri("/Pages/TrainingPage.xaml", UriKind.Relative);
            if (!FrmMain.Source.OriginalString.Contains("TrainingPage.xaml"))
            {
                FrmMain.Navigate(targetPage);
                _paintButtons(BtnTraining);
            }
        }
        
        private void BtnCultivation_Click(object sender, RoutedEventArgs e)
        {
            var targetPage = new Uri("/Pages/CultivationPage.xaml", UriKind.Relative);
            if (!FrmMain.Source.OriginalString.Contains("CultivationPage.xaml"))
            {
                FrmMain.Navigate(targetPage);
                _paintButtons(BtnCultivation);
            }
        }

        private void BtnActivity_Click(object sender, RoutedEventArgs e)
        {
            var targetPage = new Uri("/Pages/ActivityPage.xaml", UriKind.Relative);
            if (!FrmMain.Source.OriginalString.Contains("ActivityPage.xaml"))
            {
                FrmMain.Navigate(targetPage);
                _paintButtons(BtnActivity);
            }
        }

        private void BtnCultivation_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            ((Button)sender).Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
        }
    }
}
